#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
using namespace std;

class Solution {
public:
    string addStrings(string num1, string num2) {
        int carry = 0;
        string strRet;
        int end1 = num1.size() - 1;
        int end2 = num2.size() - 1;
        while (end1 >= 0 || end2 >= 0)
        {
            int val1 = end1>=0 ? num1[end1] - '0': 0;
            int val2 = end2>=0 ? num2[end2] - '0': 0;
            int sum = val1 + val2 + carry;
            carry = sum / 10;
            sum %= 10;
            strRet += (sum + '0');
            --end1;
            --end2;
        }
        if (carry == 1)
        {
            strRet += '1';
        }
        reverse(strRet.begin(), strRet.end());
        return strRet;
    }
};

int main()
{
    string num1 = "1234";
    string num2 = "56";
    Solution s1;
    string num3 = s1.addStrings(num1, num2);
    return 0;
}